<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>


<script>

    console.log(document.getElementsByTagName('p')[0])


    if (typeof (document.getElementsByTagName('p')[0])=='undefined')(
        alert(111)
    )
</script>
</body>
</html>